import time

from instools import get_current_script_folder


def get_package_name(key):
    build_type = key
    build_number = artifacts_conf_map[key].get('build_number')
    artifact_name = artifacts_conf_map[key].get('artifact_name')
    package_file_name = '{}#{}#{}'.format(build_type, build_number, artifact_name)
    return package_file_name


def get_package_folder_name(map):
    name = ''
    for key in map.keys():
        name += '{}-{}'.format(key, artifacts_conf_map[key].get('build_number'))
        name += '#'
    return name


time_str = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())

# teamcity build type
BACKEND_MAIN = ''
DATA_FILES = ''
FRONT_ADMIN = ''
FRONT_CUSTOMER = ''
FRONT_PORTAL = ''

# teamcity host info
teamcity_host_url = ''
teamcity_user = ''
teamcity_psw = ''

# build number should change as your needing
artifacts_conf_map = {
    BACKEND_MAIN: {'artifact_name': 'starter-admin.jar', 'build_number': 460},
    # DATA_FILES: {'artifact_name': 'data_files.zip', 'build_number': 23},
    # FRONT_ADMIN: {'artifact_name': 'dist.zip', 'build_number': 199},
    # FRONT_CUSTOMER: {'artifact_name': 'dist.zip', 'build_number': 156},
    # FRONT_PORTAL: {'artifact_name': 'dist.zip', 'build_number': 81},
}

# deploy machine
need_copy_to_remote = True
dst_user_name = 'root'
dst_ip = '172.16.11.147'
dst_port = 22
remote_package_folder_path = '/opt/installation_package/{}/'.format(get_package_folder_name(artifacts_conf_map))

# should  not change
package_folder_path = '{}/installation_package/{}/'.format(get_current_script_folder(),
                                                           get_package_folder_name(artifacts_conf_map))

py_script_to_package = [
    '{}/tools.py'.format(get_current_script_folder()),
    '{}/installation_make_package_conf.py'.format(get_current_script_folder()),
    '{}/installation_deploy_package.py'.format(get_current_script_folder()),
]
